package operations;

import computer.Address;
import computer.Memory;
import computer.Operand;
import computer.ProgramCounter;

public class Copy implements Operation {
	private Operand operand;
	private Address address;
	
	public Copy(Operand operand, Address address) {
		this.operand = operand;
		this.address = address;
	}

	public void execute(Memory memory, ProgramCounter programCounter) {
		memory.add(address.getIndex(),operand.getValue(memory));
		programCounter.increase();
	}
	
	public String toString() {
		StringBuilder outputString = new StringBuilder();
		outputString.append("CPY ");
		outputString.append(operand + " ");
		outputString.append(address);
		
		return outputString.toString();
	}
}